﻿<UserControl x:Class="Scrum.Net.Views.ProjectView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d">
    <UserControl.Resources>
        <DataTemplate x:Key="Project.Role.Name">
            <ComboBox 
                    DisplayMemberPath="Name" 
                    SelectedValuePath="Name"
                    SelectedValue="{Binding Role.Name}" 
                    MinWidth="0" 
                    ItemsSource="{Binding Path=DataContext.ProjectViewModel.Roles, RelativeSource={RelativeSource AncestorType=DockPanel}}"
                />
        </DataTemplate>
    </UserControl.Resources>
    <DockPanel>
        <Grid DockPanel.Dock="Top">
            <Grid.RowDefinitions>
                <RowDefinition Height="25"/>
                <RowDefinition Height="50"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="75"/>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="50"/>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="50"/>
                <ColumnDefinition Width="100"/>
            </Grid.ColumnDefinitions>

            <Label Grid.Column="0" Grid.Row="0" Content="Name:"/>
            <Label Grid.Column="0" Grid.Row="1" Content="Description:"/>
            <TextBox Grid.Column="1" Grid.Row="0" Height="22" Text="{Binding Project.Name}"/>
            <TextBox Grid.Column="1" Grid.Row="1" Height="47" Grid.ColumnSpan="5" Text="{Binding Project.Description}"/>
            <Label Grid.Column="2" Grid.Row="0" Content="Start:"/>
            <Label Grid.Column="4" Grid.Row="0" Content="End:"/>
            <DatePicker Grid.Column="3" Grid.Row="0" SelectedDate="{Binding Project.Start}"/>
            <DatePicker Grid.Column="5" Grid.Row="0" SelectedDate="{Binding Project.End}"/>
        </Grid>

        <TabControl DockPanel.Dock="Top">
            <TabItem Header="Backlog">
                <DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Button DockPanel.Dock="Left" Content="new Story" Command="{Binding ProjectViewModel.NewStoryCommand}"/>
                        <Button DockPanel.Dock="Left" Content="delete Story" Command="{Binding ProjectViewModel.DeleteStoryCommand}"/>
                    </DockPanel>
                    <DataGrid DockPanel.Dock="Top" ItemsSource="{Binding Project.Backlog}" SelectedItem="{Binding ProjectViewModel.SelectedProjectBacklog}" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Name" Width="200" Binding="{Binding Name}"/>
                            <DataGridTextColumn Header="Description" Width="400" Binding="{Binding Description}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </DockPanel>
            </TabItem>
            <TabItem Header="User">
                <DockPanel>
                    <DockPanel DockPanel.Dock="Top">
                        <Button DockPanel.Dock="Left" Content="new User" Command="{Binding ProjectViewModel.NewUserCommand}"/>
                        <Button DockPanel.Dock="Left" Content="delete User" Command="{Binding ProjectViewModel.DeleteUserCommand}"/>
                    </DockPanel>
                    <DataGrid DockPanel.Dock="Top" ItemsSource="{Binding Project.Users}" SelectedItem="{Binding ProjectViewModel.SelectedProjectUser}" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Id" Width="50" Binding="{Binding Id}"/>
                            <DataGridTextColumn Header="Name" Width="200" Binding="{Binding Name}"/>
                            <DataGridTemplateColumn Header="Role" Width="100" CellEditingTemplate="{StaticResource Project.Role.Name}">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Role.Name}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn Header="available hours per day" Width="50" Binding="{Binding AvailableHours}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </DockPanel>
            </TabItem>
        </TabControl>
    </DockPanel>
</UserControl>
